package com.hjm.project.agentInfo.accountDetails.controller;

import java.util.List;

import com.hjm.framework.config.CustomConfig;
import com.hjm.project.clientImg.clientImg.domain.ClientImg;
import com.hjm.project.clientImg.clientImg.service.IClientImgService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.agentInfo.accountDetails.domain.AccountDetails;
import com.hjm.project.agentInfo.accountDetails.service.IAccountDetailsService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 充值详情Controller
 * 
 * @author generator
 * @date 2020-11-27
 */
@Controller
@RequestMapping("/agentInfo/accountDetails")
public class AccountDetailsController extends BaseController
{
    private String prefix = "agentInfo/accountDetails";

    @Autowired
    private IAccountDetailsService accountDetailsService;

    @Autowired
    private IClientImgService clientImgService;

    @RequiresPermissions("agentInfo:accountDetails:view")
    @GetMapping()
    public String accountDetails()
    {
        return prefix + "/accountDetails";
    }

    /**
     * 查询充值详情列表
     */
    @RequiresPermissions("agentInfo:accountDetails:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AccountDetails accountDetails)
    {
        startPage();
        List<AccountDetails> list = accountDetailsService.selectAccountDetailsList(accountDetails);
        return getDataTable(list);
    }

    /**
     * 导出充值详情列表
     */
    @RequiresPermissions("agentInfo:accountDetails:export")
    @Log(title = "充值详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AccountDetails accountDetails)
    {
        List<AccountDetails> list = accountDetailsService.selectAccountDetailsList(accountDetails);
        ExcelUtil<AccountDetails> util = new ExcelUtil<AccountDetails>(AccountDetails.class);
        return util.exportExcel(list, "accountDetails");
    }


    /**
     * 充值凭证
     */
    @GetMapping("/viewVoucher")
    public String viewVoucher(String agentNum, String serial, ModelMap map)
    {
        ClientImg clientImg=new ClientImg();
        clientImg.setClientno(agentNum);
        clientImg.setClientSerial(serial);
        clientImg.setObjType(1L);
        clientImg.setType(34L);
        List<ClientImg> clientImages = clientImgService.selectclientImgList(clientImg);
        map.put("clientImages", clientImages);
        map.put("imgUrl", CustomConfig.getImgUrl());
        return prefix + "/viewVoucher";
    }
}
